import apis from './apis';
import dayjs from 'dayjs';
import DingClient from './DingClient';
import constants from '@/constant';

const propsList = [
  {
    name: '$api',
    value: apis
  },
  {
    name: '$dayjs',
    value: dayjs
  },
  {
    name: '$dd',
    value: DingClient
  },
  {
    name: '$const',
    value: constants
  }
];

const generateProps = (propsList) => {
  const props = {};
  propsList.forEach(({ name, value }) => {
    props[name] = { value };
  });
  return props;
};

export default function install (Vue) {
  Object.defineProperties(Vue.prototype, { ...generateProps(propsList) });
}
